#ifndef frm_control_TPara_H
#define frm_control_TPara_H

#include "frm_control_TLine.h"

namespace frm { namespace control {

///////////////////////////////////////////////////////////////////////////////

struct TPara : public TPanel
{
  struct TStyle : public frm::TStyle
  {
    svl_Type(frm::TStyle)
    TPanel::TStyle Normal,Selected,Focused;
    TLine::TStyle Line;
    //
    virtual void SetFromParent(frm::TStyle *Parent);
    virtual svl::TInfoParam AddInfoTo(svl::TInfoParam Info);
  };
  ///////////////
  struct TOptions
  {
    bool EnProcKeyPgUp_KeyPgDown;
    //
    TOptions() { EnProcKeyPgUp_KeyPgDown = false; }
  }
  Options;
  //
  TLine *FirstLine;
  //
  svl_Type(TPanel)
  TPara(TWindow &Window);
 ~TPara();
  //
  TPara  &SetStyle(TStyle &V);
  TStyle &GetStyle() { return *style;}
  //
  struct TTempDisableFormatting
  {
    TTempDisableFormatting(TPara *P) : p(*P) { old = P->enFormatting; P->enFormatting = false; }
   ~TTempDisableFormatting()                 { p.enFormatting = old; }
  private:
    bool old; TPara &p;
  };
  friend TTempDisableFormatting;
  //
  void SetEnFormatting(bool V = false);
  bool GetEnFormatting() { return enFormatting;}
  //
  void Formatting(int ParaWidth);
  void Formatting() { Formatting(GetClientWidth()); }
  //
  void SetEnProcChangeWidth(bool V = true) { enProcChangeWidth = V; } 
  bool GetEnProcChangeWidth()              { return enProcChangeWidth;}
  //
  void Clear();
  void Child_AfterChangeWidth(int OldVal,int NewVal);

protected:
  virtual void TComponent_AddToParent(TComponent *Parent);
  virtual void TComponent_Mouse(TMouse Mouse);
  virtual void TComponent_KeyboardKey(grf::TKeyboardKey &KeyboardKey);
  //
  virtual bool TComponent_SelectEnable() { return true;}
  virtual void TComponent_SelectEnter ();
  virtual void TComponent_SelectExit  ();
  //
  virtual bool TComponent_FocusEnable() { return true;}
  virtual void TComponent_FocusEnter();
  virtual void TComponent_FocusExit ();
  virtual void TComponent_InheritStyleFrom(TTableOfStyles &ParentStyles);
  //
  TLine *NewLine();

private:
  virtual void TComponent_AfterCalcAll() { Formatting();}
  virtual void TComponent_AfterChangeWidth(int OldVal,int NewVal);
  //
  struct TPostFormatting : public svl::TPostMessage
  {
    TPara &para; TPostFormatting(TPara &Para);
    virtual void TPostMessage_Receive();
  };
  friend TPostFormatting;
  //
  bool enFormatting,enProcChangeWidth;
  TStyle *style;
};

///////////////////////////////////////////////////////////////////////////////
}}

#endif
